package com.demo.wrapper.interfaces;

import com.demo.wrapper.function.IGetter;
import com.demo.wrapper.enums.OrderEnum;

/**
 * 全局限制
 *
 * @param <Wrapper>    条件拼接类，需继承Limit接口
 * @param <AggWrapper> 聚合拼接类，需继承Agg接口
 * @param <DO>         文档实体类
 * @author arthur_zhou
 */
public interface IEsLambdaLimitWrapper<Wrapper extends IEsLambdaLimitWrapper<Wrapper, DO, AggWrapper>, DO, AggWrapper extends IEsAggWrapper<AggWrapper, Wrapper>>
        extends IEsLimitWrapper<Wrapper, AggWrapper>, ILambdaWrapper<Wrapper, DO> {

    /**
     * 展示字段
     *
     * @param getter  字段
     * @param getters 更多字段
     * @return
     */
    default Wrapper select(IGetter<DO> getter, IGetter<DO>... getters) {
        return select(findField(getter), findFields(getters));
    }

    /**
     * 不展示字段
     *
     * @param getter  字段
     * @param getters 更多字段
     * @return
     */
    default Wrapper notSelect(IGetter<DO> getter, IGetter<DO>... getters) {
        return notSelect(findField(getter), findFields(getters));
    }

    /**
     * 倒序
     *
     * @param getter
     * @param columns
     * @return
     */
    default Wrapper orderByDesc(IGetter<DO> getter, IGetter<DO>... columns) {
        return orderByDesc(findField(getter), findFields(columns));
    }

    /**
     * 顺序
     *
     * @param getter
     * @param getters
     * @return
     */
    default Wrapper orderByAsc(IGetter<DO> getter, IGetter<DO>... getters) {
        return orderByAsc(findField(getter), findFields(getters));
    }

    /**
     * 排序
     *
     * @param getter
     * @param order
     * @return
     */
    default Wrapper sort(IGetter<DO> getter, OrderEnum order) {
        return sort(findField(getter), order);
    }

}
